import * as actionTypes from '../constants/home';

import {fromJS} from 'immutable';

const defaultState = fromJS({
    topicList: [],
    articleList: [],
    recommendList: [],
    showBackToTop: false
});

export default (state = defaultState, action) => {

    switch (action.type) {

        case actionTypes.GET_TOPIC_LIST:
            return state.set('topicList', action.data);

        case actionTypes.GET_ARTICLE_LIST:
            return state.set('articleList', action.data);

        case actionTypes.GET_RECOMMEND_LIST:
            return state.set('recommendList', action.data);

        case actionTypes.CHANGE_BACKTOTOP_SHOW:
            return  state.set('showBackToTop', action.isShow);

        default:
            return state;

    }

}